﻿using LogisticsTrackingWebApi_V2.Models;
using LogisticsTrackingWebApi_V2.Services;

namespace LogisticsTrackingWebApi_V2.ServicesImpl
{
    /// <summary>
    /// 圆通物流查询实现
    /// </summary>
    public class YTOExpressProvider : ILogisticsProvider
    {
        public string CompanyCode => "YTO";
        public string CompanyName => "圆通速递";

        public async Task<LogisticsInfo> QueryLogisticsAsync(string trackingNumber)
        {
            // 实际项目中这里会调用圆通的API
            await Task.Delay(150); // 模拟API调用延迟

            return new LogisticsInfo
            {
                TrackingNumber = trackingNumber,
                CompanyCode = CompanyCode,
                CompanyName = CompanyName,
                Status = LogisticsStatus.Delivered,
                LastUpdated = DateTime.Now.AddDays(-1),
                TrackingRecords = new List<TrackingRecord>
            {
                new TrackingRecord { Time = DateTime.Now.AddDays(-1), Location = "北京市朝阳区", Description = "快件已签收" },
                new TrackingRecord { Time = DateTime.Now.AddDays(-1).AddHours(-2), Location = "北京市朝阳区", Description = "快递员正在派送中" },
                new TrackingRecord { Time = DateTime.Now.AddDays(-2), Location = "北京市", Description = "快件已到达目的地网点" }
            }
            };
        }
    }

}
